<%@ page import="com.situ.web.entity.Student" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.situ.web.vo.StudentBanjiVO" %><%--
  Created by IntelliJ IDEA.
  User: Gao
  Date: 2021/8/10
  Time: 16:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/bootstrap-3.4.1-dist/css/bootstrap.css"/>
</head>
<body>
   <%--${list}--%>
   <%--<a class="btn btn-primary" href="<%=request.getContextPath()%>/student?method=getStudentInsertPage">添加</a>--%>
   <a class="btn btn-primary" href="<%=request.getContextPath()%>/student_insert.jsp">添加</a>
   <table class="table table-striped table-bordered table-hover table-condensed">
       <tr>
           <td>ID2</td>
           <td>名字</td>
           <td>年龄</td>
           <td>性别</td>
           <td>班级名字</td>
           <td>删除/修改</td>
       </tr>
       <%
            // request：内置对象（这个对象已经创建好了，名字也起好了就叫request）
            // 在这里面可以写java代码
           ArrayList<StudentBanjiVO> list = (ArrayList<StudentBanjiVO>) request.getAttribute("list");
           for (StudentBanjiVO studentBanji : list) {
       %>
               <tr>
                   <td><%=studentBanji.getStudentId()%></td>
                   <td><%=studentBanji.getStudentName()%></td>
                   <td><%=studentBanji.getStudentAge()%></td>
                   <td><%=studentBanji.getStudentGender()%></td>
                   <td><%=studentBanji.getBanjiName()%></td>
                   <%--<td><a href="<%=request.getContextPath()%>/student?method=deleteById&id=<%=student.getId()%>">删除</a></td>--%>
                   <td>
                       <a class="btn btn-danger btn-sm" href="javascript:void(0)" onclick="deleteById(<%=studentBanji.getStudentId()%>)">删除</a>
                       <a class="btn btn-warning btn-sm" href="<%=request.getContextPath()%>/student?method=selectById&id=<%=studentBanji.getStudentId()%>" >编辑</a>
                   </td>
               </tr>
       <%
           }
       %>

   </table>

    <script type="text/javascript">
        function deleteById(id) {
            var isDelete = confirm('您确认要删除么？');
            if(isDelete) {
                location.href = '<%=request.getContextPath()%>/student?method=deleteById&id=' + id;
            }
        }
    </script>
</body>
</html>
